import { Action } from '@ngrx/store';
import { Task, User, TaskList } from '../domain/index';

/**
 * For each action type in an action group, make a simple
 * enum object for all of this group's action types.
 */
export enum TaskActionTypes {
    ADD = '[Task] Add',
    ADD_SUCCESS = '[Task] Add Success',
    ADD_FAIL = '[Task] Add Fail',
    UPDATE = '[Task] Update',
    UPDATE_SUCCESS = '[Task] Update Success',
    UPDATE_FAIL = '[Task] Update Fail',
    DELETE = '[Task] Delete',
    DELETE_SUCCESS = '[Task] Delete Success',
    DELETE_FAIL = '[Task] Delete Fail',
    LOAD = '[Task] Load',
    LOAD_SUCCESS = '[Task] Load Success',
    LOAD_FAIL = '[Task] Load Fail',
    MOVE = '[Task] Move',
    MOVE_SUCCESS = '[Task] Move Success',
    MOVE_FAILE = '[Task] Move Fail',
    MOVE_ALL = '[Task] MoveAll',
    MOVE_ALL_SUCCESS = '[Task] MoveAll Success',
    MOVE_ALL_FAILE = '[Task] MoveAll Fail',
    COMPLETE = '[Task] Complete',
    COMPLETE_SUCCESS = '[Task] Complete Success',
    COMPLETE_FAILE = '[Task] Complete Fail'
}

/**
 * Every action is comprised of at least a type and an optional
 * payload. Expressing actions as classes enables powerful
 * type checking in reducer functions.
 */
export class TaskAddAction implements Action {
    readonly type = TaskActionTypes.ADD;
    constructor(public payload: Task) { }
}

export class TaskAddSuccessAction implements Action {
    readonly type = TaskActionTypes.ADD_SUCCESS;
    constructor(public payload: Task) { }
}
export class TaskAddFailAction implements Action {
    readonly type = TaskActionTypes.ADD_FAIL;
    constructor(public payload: string) { }
}

export class TaskUpdateAction implements Action {
    readonly type = TaskActionTypes.UPDATE;
    constructor(public payload: Task) { }
}

export class TaskUpdateSuccessAction implements Action {
    readonly type = TaskActionTypes.UPDATE_SUCCESS;
    constructor(public payload: Task) { }
}
export class TaskUpdateFailAction implements Action {
    readonly type = TaskActionTypes.UPDATE_FAIL;
    constructor(public payload: string) { }
}

export class TaskDeleteAction implements Action {
    readonly type = TaskActionTypes.DELETE;
    constructor(public payload: Task) { }
}

export class TaskDeleteSuccessAction implements Action {
    readonly type = TaskActionTypes.DELETE_SUCCESS;
    constructor(public payload: Task) { }
}

export class TaskDeleteFailAction implements Action {
    readonly type = TaskActionTypes.DELETE_FAIL;
    constructor(public payload: string) { }
}

export class TaskLoadAction implements Action {
    readonly type = TaskActionTypes.LOAD;
    constructor(public payload: TaskList[]) { }
}

export class TaskLoadSuccessAction implements Action {
    readonly type = TaskActionTypes.LOAD_SUCCESS;
    constructor(public payload: Task[]) { }
}
export class TaskLoadFailAction implements Action {
    readonly type = TaskActionTypes.LOAD_FAIL;
    constructor(public payload: string) { }
}
export class TaskMoveAction implements Action {
    readonly type = TaskActionTypes.MOVE;
    constructor(public payload: { taskId: string; taskListId: string }) { }
}

export class TaskMoveSuccessAction implements Action {
    readonly type = TaskActionTypes.MOVE_SUCCESS;
    constructor(public payload: Task) { }
}
export class TaskMoveFailAction implements Action {
    readonly type = TaskActionTypes.MOVE_FAILE;
    constructor(public payload: string) { }
}

export class TaskMoveAllAction implements Action {
    readonly type = TaskActionTypes.MOVE_ALL;
    constructor(public payload: { srclistId: string; target: string }) { }
}

export class TaskMoveAllSuccessAction implements Action {
    readonly type = TaskActionTypes.MOVE_ALL_SUCCESS;
    constructor(public payload: Task[]) { }
}
export class TaskMoveAllFailAction implements Action {
    readonly type = TaskActionTypes.MOVE_ALL_FAILE;
    constructor(public payload: string) { }
}

export class TaskCompleteAction implements Action {
    readonly type = TaskActionTypes.COMPLETE;
    constructor(public payload: Task) { }
}

export class TaskCompleteSuccessAction implements Action {
    readonly type = TaskActionTypes.COMPLETE_SUCCESS;
    constructor(public payload: Task) { }
}
export class TaskCompleteFailAction implements Action {
    readonly type = TaskActionTypes.COMPLETE_FAILE;
    constructor(public payload: string) { }
}
/**
 * Export a type alias of all actions in this action group
 * so that reducers can easily compose action types
 */
export type TaskActions
    = TaskAddAction
    | TaskAddSuccessAction
    | TaskAddFailAction
    | TaskUpdateAction
    | TaskUpdateSuccessAction
    | TaskUpdateFailAction
    | TaskDeleteAction
    | TaskDeleteSuccessAction
    | TaskDeleteFailAction
    | TaskLoadAction
    | TaskLoadSuccessAction
    | TaskLoadFailAction
    | TaskMoveAction
    | TaskMoveSuccessAction
    | TaskMoveFailAction
    | TaskMoveAllAction
    | TaskMoveAllSuccessAction
    | TaskMoveAllFailAction
    | TaskCompleteAction
    | TaskCompleteSuccessAction
    | TaskCompleteFailAction;
